#include "Facade.h"

#include "memoryData.h"

using namespace std;


namespace mem {

int initMemoryData(std::map<std::string, std::string> & map) {
    auto _extractMaxCount = [](std::map<string, string> & map, const std::string & key, int defaultValue ){
        auto it = map.find(key);
        return it != map.end() ? std::stoi(it->second)  : defaultValue;
    };
    int maxOrderCount = _extractMaxCount(map, "MAX_BAODAN_COUNT", MAX_BAODAN_COUNT);
    if (maxOrderCount == 0) maxOrderCount = MAX_BAODAN_COUNT;

    int maxMatchCount = _extractMaxCount(map, "MAX_CHENGJIAODAN_COUNT", MAX_CHENGJIAODAN_COUNT);
    if(maxMatchCount == 0) maxMatchCount = MAX_CHENGJIAODAN_COUNT;

    return mem::initMemoryData(maxOrderCount, maxMatchCount);
}

}// namespace mem
